<?php

namespace TableTennis\LicenseeBundle\Admin;

use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Validator\ErrorElement;
use Sonata\AdminBundle\Form\FormMapper;

class LicenseeAdmin extends Admin
{
    protected function configureFormFields(FormMapper $formMapper)
    {
        $formMapper
            ->with('Contenu')
                ->add('licensee_number', null, array('label' => 'N° licence'))
                ->add('lastname', null, array('label' => 'Nom'))
                ->add('firstname', null, array('label' => 'Prénom'))
            ->end()
            ->with('Options')
              ->add('licensee_user_id', null, array('label' => 'Utilisateur'))
              ->add('club_id', null, array('label' => 'Club'))
              ->add('team_id', null, array('label' => 'Equipe'))
              ->add('category', null, array('label' => 'Catégorie'))
              ->add('status', 'choice', array('choices' => array('play'=> 'Joue', 'rest' => 'En repos')))
            ->end()
            ->with('Infos générales')
               ->add('created_at', 'datetime', array('label' => 'Date de création')) //'data' => new \DateTime('now')
               ->add('updated_at', 'datetime', array('label' => 'Date de modification'))
               ->add('creation_user_id', null, array('label' => 'Créé par'))
               ->add('modification_user_id', null, array('label' => 'Modifié par'))
            ->end()

        ;
    }

    protected function configureDatagridFilters(DatagridMapper $datagridMapper)
    {
        $datagridMapper
            ->add('licensee_number')
            ->add('lastname')
            ->add('firstname')
        ;
    }

    protected function configureListFields(ListMapper $listMapper)
    {
        $listMapper
            ->addIdentifier('licensee_number')
            ->add('lastname')
            ->add('firstname')
        ;
    }

    /*public function validate(ErrorElement $errorElement, $object)
    {

    }*/
}

?>